

export interface Device {
    id: number,
    name: string,
    mac_addr: string,
    location: string,
    currency_code: string,
    lang: string,
    money: number,
}

export const CURRENCY_CODES = [
    'CNY',
    'EUR',
];

export const LANGS = [
    'zhCN',
    'es',
    'it',
    'fr'
];

export const MONEYS = [
    1,
    10,
    100
]

export const FIRM_TYPE = [
    '上位机',
    '下位机',
];

export type QueryRes = Device[];

export interface ErrInfo {
    err_code: number,
    err_msg: string,
}

export interface Event {
    type: number,
    seq: number | null,
    cmd: number | null,
    ec: number | null,
    body: Uint8Array,
}

export interface LoginReq {
    account: string,
    pwd: string,
}

export interface User {
    id: number,
    name: string,
    account: string,
    pwd_enc: string,
}

export type LoginRes = User;

export interface Firm {
    id: number,
    name: string,
    create_timestamp: number,
    size: number,
    description: string,
    version: string,
}

export interface Product {
    id: number,
    name: string,
    price: number,
    image: Uint8Array,
}

export function createObjectUrl(body: Uint8Array) {
    const url = URL.createObjectURL( new Blob([body]) );
    return url
}

export interface Product2 {
    id: number,
    name: string,
    price: number,
    image_id: number,
}


